<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>京东(JD.COM)-综合网购首选-正品低价、品质保障、配送及时、轻松购物！</title>
    <meta name="description"
        content="京东JD.COM-专业的综合网上购物商城,销售家电、数码通讯、电脑、家居百货、服装服饰、母婴、图书、食品等数万个品牌优质商品.便捷、诚信的服务，为您提供愉悦的网上购物体验!" />
    <meta name="Keywords" content="网上购物,网上商城,手机,笔记本,电脑,MP3,CD,VCD,DV,相机,数码,配件,手表,存储卡,京东" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="css/normalize.css" />
    <link rel="stylesheet" href="css/base.css" />
    <link rel="stylesheet" href="css/detail.css" />
    <script src="js/jquery.min.js"></script>
    <script src="js/base.js"></script>
    <script src="js/detail.js"></script>
    <script src="js/axios.min.js"></script>
    <!-- import Vue before Element -->
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <!-- import JavaScript -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>

<body>
    <div id="app">
        <header>
            <a href="#">
                <img src="images/header.jpg" height="80" width="100%" alt="">
            </a>
        </header>
        <div>
            <iframe MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no src="heade.html" height="30px" width="100%"></iframe>
               </div>
        <div class="m">
            <div class="w middle">
                <div class="logo">
                    <h1>
                        <!-- 提高权重 便利于搜索引擎优化 -->
                        <a href="index.html" title="京东">京东</a>
                    </h1>
                </div>
                <div class="form">
                    <input id="text" type="text" placeholder="扫描仪">
                    <button><i></i></button>
                </div>
                <div class="shopCar">
                    <i></i><a href="cart.html" class="f10">我的购物车</a><span>8</span>
                </div>
                <div class="hotwords">
                    <a href="#" class="f10">199减100</a>
                    <a href="#">鼠标试用</a>
                    <a href="#">农资7折</a>
                    <a href="#">低至29元</a>
                    <a href="#">抽奖赢空调</a>
                    <a href="#">记忆棉</a>
                    <a href="#">坐垫</a>
                    <a href="#">1分钱买油</a>
                    <a href="#">智能手表</a>
                </div>

                <div class="super">
                    <a href="#"><img src="images/super.png" alt=""></a>
                </div>
            </div>
        </div>
        <div class="de_container">
            <div class="w">
                <div class="crumb_wrap">
                    <a href="#">{{userInfo.name}}店铺</a>
                </div>
                <div class="product_intro">
                    <div class="preview_wrap fl">
                        <div class="preview_img">
                            <img :src="lastimg" width="100%" alt="">
                            <div class="mask"></div>
                            <div class="big">
                                <img :src="lastimg" width="800px" alt="" class="bigimg">
                            </div>
                        </div>
                        <div class="preview_list">
                            <a href="javascript:;" class="arrow_prev"><</a>
                            <a href="javascript:;" class="arrow_next">></a>
                                    <ul class="list_item">
                                        <li class="im" v-for='commodity in commodity.commodityBanner'>
                                            <img :src="commodity.image" alt="" width="56px">
                                        </li>
                                    </ul>
                        </div>
                    </div>
                    <div class="itemInfo_wrap fr">
                        <div class="sku_name">
                            {{commodity.exName}}
                        </div>

                        <div class="summary">
                            <dl class="summary_price">
                                <dt>闪购价</dt>
                                <dd>
                                    <i class="price">{{commodity.price}}</i>
                                </dd>
                            </dl>


                            <dl class="choose_color">
                                <dt>选择颜色</dt>
                                <dd>
                                    <!-- <a class="ex current" @click='getCommodityByNum(commodity.itemNumber)'>
                                        <img width="40px" :src='commodity.exhibition'/>
                                    </a> -->
                                    <a class="ex" v-for='commodity in commodityList'
                                        @click='getCommodityByNum(commodity.itemNumber)'>
                                        <img width="40px" :src='commodity.exhibition' />
                                    </a>
                                </dd>
                            </dl>

                            <dl class="choose_version">
                                <dt>内存容量</dt>
                                <dd>
                                    <a href="javasript:;">
                                        {{commodity.specifications}}
                                    </a>
                                </dd>
                            </dl>


                            <div style="float: left;">
                                <el-button @click='reduce' style="height: 46px;">-</el-button>
                                <input type="text" size="1"
                                    style="border: 1px solid white;height: 44px;text-align: center;" v-model='number'>
                                <el-button @click='add' style="height: 46px;">+</el-button>
                            </div>

                            <a @click='addCart' v-if="commodity.stock != 0" class="addCar">加入购物车</a>
                            <a style="background-color: #f3f3f3;color: rgb(153, 150, 150);" v-if="commodity.stock == 0" class="addCar">已告罄</a>
                        </div>
                    </div>
                </div>
                <div class="product_detail">
                    <div class="aside fl">
                        <div class="tab_list">
                            <ul>
                                <li class="first_tab" style="width: 208px;">猜你喜欢</li>
                            </ul>
                        </div>
                        <div class="tab_con">
                            <ul>
                                <a v-for='like in likeList' @click='gotoDetail(like.itemNumber)' target="_blank">
                                    <li>
                                        <img :src="like.exhibition" width="100%" alt="">
                                        <h5>{{like.exName}}</h5>
                                        <div class="aside_price">￥{{like.price}}</div>
                                    </li>
                                </a>

                            </ul>
                        </div>
                    </div>
                    <div class="detail fr">
                        <div class="detail_tab_list">
                            <ul>
                                <li class="current">商品介绍</li>
                            </ul>
                        </div>
                        <div class="detail_tab_con">
                            <div class="item">
                                <ul class="item_info">
                                    <li>商品名称：华为P30 Pro</li>
                                    <li>商品编号：100004323294</li>
                                    <li>商品毛重：0.54kg</li>
                                    <li>商品产地：中国大陆</li>
                                    <li>CPU型号：麒麟980</li>
                                    <li>运行内存：8GB</li>
                                    <li>机身内存：128GB</li>
                                    <li>存储卡：NM存储卡</li>
                                    <li>摄像头数量：后置四摄</li>
                                    <li>后置摄像头：4000万像素</li>
                                    <li>前置摄像头：3200万像素</li>
                                    <li>分辨率：全高清FHD+</li>
                                    <li>热点：人脸识别，快速充电，无线充电，液冷散热，高倍率变焦，屏幕指纹，防水防尘，NFC，曲面屏</li>
                                    <li>操作系统：Android(安卓)</li>
                                </ul>
                                <img v-for='tatilsImage in commodity.tatilsImage' :src="tatilsImage.image" alt="">
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <footer>
            <div class="service">
                <!-- 服务模块 -->
                <div class="w">
                    <ul>
                        <li>
                            <h5></h5>
                            <p>品类齐全，轻松购物</p>
                        </li>
                        <li>
                            <h5></h5>
                            <p>品类齐全，轻松购物</p>
                        </li>
                        <li>
                            <h5></h5>
                            <p>品类齐全，轻松购物</p>
                        </li>
                        <li>
                            <h5></h5>
                            <p>品类齐全，轻松购物</p>
                        </li>
                    </ul>
                </div>
            </div>
            <!-- 帮助模块 -->
            <div class="w help">
                <div class="fl">
                    <dl>
                        <dt>购物指南</dt>
                        <dd><a href="#">购物流程</a></dd>
                        <dd><a href="#">会员介绍</a></dd>
                        <dd><a href="#">生活旅行</a></dd>
                        <dd><a href="#">常见问题</a></dd>
                        <dd><a href="#">大家电</a></dd>
                        <dd><a href="#">联系客服</a></dd>
                    </dl>
                    <dl>
                        <dt>配送方式</dt>
                        <dd><a href="#">上门自提</a></dd>
                        <dd><a href="#">211限时达</a></dd>
                        <dd><a href="#">配送服务查询</a></dd>
                        <dd><a href="#">配送费收取标准</a></dd>
                        <dd><a href="#">海外配送</a></dd>
                    </dl>
                    <dl>
                        <dt>支付方式</dt>
                        <dd><a href="#">货到付款</a></dd>
                        <dd><a href="#">在线支付</a></dd>
                        <dd><a href="#">分期付款</a></dd>
                        <dd><a href="#">邮局汇款</a></dd>
                        <dd><a href="#">公司转账</a></dd>
                    </dl>
                    <dl>
                        <dt>售后服务</dt>
                        <dd><a href="#">售后政策</a></dd>
                        <dd><a href="#">价格保护</a></dd>
                        <dd><a href="#">退款说明</a></dd>
                        <dd><a href="#">返修/退换货</a></dd>
                        <dd><a href="#">取消订单</a></dd>
                    </dl>
                    <dl>
                        <dt>特色服务</dt>
                        <dd><a href="#">夺宝岛</a></dd>
                        <dd><a href="#">DIY装机</a></dd>
                        <dd><a href="#">延保服务</a></dd>
                        <dd><a href="#">京东E卡</a></dd>
                        <dd><a href="#">京东通信</a></dd>
                        <dd><a href="#">京鱼座智能</a></dd>
                    </dl>
                </div>
                <div class="fr coverage">
                    <h5>京东自营覆盖区县</h5>
                    <p>京东已向全国2661个区县提供自营配送服务，支持货到付款、POS机刷卡和售后上门服务。</p>
                    <a href="#">查看详情 > </a>
                </div>
            </div>
            <div class="w copyright">
                <p>
                    <a href="#">关于我们</a>
                    <span> | </span>
                    <a href="#">联系我们</a>
                    <span> | </span>
                    <a href="#">联系客服</a>
                    <span> | </span>
                    <a href="#">合作招商</a>
                    <span> | </span>
                    <a href="#">商家帮助</a>
                    <span> | </span>
                    <a href="#">营销中心</a>
                    <span> | </span>
                    <a href="#">手机京东</a>
                    <span> | </span>
                    <a href="#">友情链接</a>
                    <span> | </span>
                    <a href="#">销售联盟</a>
                    <span> | </span>
                    <a href="#">京东社区</a>
                    <span> | </span>
                    <a href="#">风险监测</a>
                    <span> | </span>
                    <a href="#">隐私政策</a>
                    <span> | </span>
                    <a href="#">京东公益</a>
                    <span> | </span>
                    <a href="#">English Site</a>
                    <span> | </span>
                    <a href="#">Media & IR</a>
                </p>
                <div>
                    <p>京公网安备
                        11000002000088号<span>|</span>京ICP证070359号<span>|</span>互联网药品信息服务资格证编号(京)-经营性-2014-0008<span>|</span>新出发京零
                        字第大120007号</p>
                    <p>互联网出版许可证编号新出网证(京)字150号<span>|</span>出版物经营许可证<span>|</span>网络文化经营许可证京网文[2014]2148-348号<span>|</span>违法和不良信息举报电话：4006561155
                    </p>
                    <p>Copyright © 2004 - 2019 京东JD.com
                        版权所有<span>|</span>消费者维权热线：4006067733经营证照|(京)网械平台备字(2018)第00003号<span>|</span>营业执照</p>
                    <p>Global Site<span>|</span>Сайт России<span>|</span>Situs Indonesia<span>|</span>Sitio de
                        España<span>|</span>เว็บไซต์ประเทศไทย</p>
                    <p>京东旗下网站：京东钱包<span>|</span>京东云</p>
                </div>
                <p class="foot-icon">
                    <a href="#"></a>
                    <a href="#"></a>
                    <a href="#"></a>
                    <a href="#"></a>
                    <a href="#"></a>
                    <a href="#"></a>
                </p>
            </div>
        </footer>
    </div>
</body>

<script>
    new Vue({
        el: '#app',
        data: {
            commodity: {},//存放当前商品对象
            commodityList: [],//存放其他型号对象
            itemNumber: '',//商品编号
            lastimg: null,//存放第一件商品的图片，用于展示
            likeList: [],//存放猜你喜欢的商品对象
            number: 1,//商品数量
            token:'',
            userInfo:''
        },
        created() {
            this.showInfo();
            this.itemNumber = this.GetURLParameter("itemNumber");
            this.getCommodityNode(this.itemNumber);
            this.getList();
        },
        methods: {
            showInfo() {
                let token = this.getCookie("token");
                if (token == "" || token == null) {
                    // window.location.href = 'login.html';
                }else{
                    this.token = token;
                }
            },
            //根据编号获取当前商品的所有信息以及同型号商品信息
            getCommodityNode(itemNumber) {
                axios.get(`http://localhost/admin/commodity/getCommodityNode/${itemNumber}`)
                    .then(response => {
                        let resData = response.data;
                        this.commodity = resData.data;
                        this.lastimg = this.commodity.commodityBanner[0].image;
                        this.commodityList = this.commodity.commodityInfo;
                        this.userInfo = this.commodity.userInfo;
                    })
            },
            //根据编号获取当前商品的所有信息
            getCommodityByNum(itemNumber) {
                axios.get(`http://localhost/admin/commodity/getCommodityByNum/${itemNumber}`)
                    .then(response => {
                        let resData = response.data;
                        this.commodity = resData.data;
                        this.lastimg = this.commodity.commodityBanner[0].image;
                        this.itemNumber = this.commodity.itemNumber;
                    })
            },
            //随机获取几件商品，放入猜你喜欢
            getList() {
                axios.get(`http://localhost/admin/commodity/findAll/1/6`)
                    .then(response => {
                        let resData = response.data.data;
                        this.likeList = resData.data;
                    })
            },
            //前往商品详情页
            gotoDetail(itemNumber) {
                window.open('detail.html?itemNumber=' + itemNumber);
            },
            //将商品添加至购物车
            addCart() {
                if(this.token == '' || this.token == null){
                    window.open("login.html");
                    return;
                }
                let param = new URLSearchParams()
                param.append('itemNumber', this.itemNumber)
                param.append('number', this.number)
                param.append('token', this.token)
                axios.post(`http://localhost/admin/user/cart/addCommodity`,param)
                .then(response => {
                    this.$notify({
                        title: '成功',
                        message: '添加成功，快去剁手吧',
                        type: 'success'
                    });
                })
            },
            add() {
                if (this.number < 199) this.number++;
            },
            reduce() {
                if (this.number > 1) this.number--;
            },
            GetURLParameter(sParam) {
                let sPageURL = window.location.search.substring(1);
                let sURLVariables = sPageURL.split("&");
                for (let i = 0; i < sURLVariables.length; i++) {
                    let sParameterName = sURLVariables[i].split('=');
                    if (sParameterName[i] == sParam) {
                        return sParameterName[i + 1];
                    }
                }
            },
            getCookie(name) {
                var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
                if (arr = document.cookie.match(reg)) {
                    return unescape(arr[2]);

                } else {
                    return null;
                }
            }

        }
    })
</script>
<script>
    $(function () {
        $("body").bind('mouseover', function () {
            // $('.im').addCss('current');
            $('.im:first').addClass('current')
            $('.im:first').addClass('current')
            $("body").unbind('mouseover');

        })
        $(".im").bind('mouseover', function () {
            // $('.im').addCss('current');
            $('.im:first').removeClass('current')
        })


    })
</script>

</html>